<template>
    <div class="home">
        <div class="outer">
            <el-container style="border: 1px solid #eee;height: 100%">
                <el-header style="text-align: right; font-size: 12px">
                    <span style="float: left;font-size: large">树莓派环境监测系统</span>
                    <div @click="logout">
                        <el-dropdown>
                            <i class="el-icon-circle-close" style="margin-right: 15px"></i>
                            <span>退出登录</span>
                        </el-dropdown>
                    </div>
                </el-header>
                <el-container>
                    <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
                        <el-menu default-active="1">
                            <el-menu-item index="1" @click="goRoute('dashboard')">
                                <i class="el-icon-menu"></i>
                                <span slot="title">
                                    控制台
                                </span>
                            </el-menu-item>
                            <el-menu-item index="2" @click="goRoute('dataAnalyzeTable')">
                                <i class="el-icon-setting"></i>
                                <span slot="title">数据表格</span>
                            </el-menu-item>
                            <el-menu-item index="3" @click="goRoute('dataAnalyzeCharts')">
                                <i class="el-icon-setting"></i>
                                <span slot="title">可视化分析</span>
                            </el-menu-item>
                            <el-menu-item index="4" @click="goRoute('changePassword')">
                                <i class="el-icon-setting"></i>
                                <span slot="title">修改密码</span>
                            </el-menu-item>
                        </el-menu>
                    </el-aside>
                    <el-main>
                        <router-view></router-view>
                    </el-main>
                </el-container>
            </el-container>
        </div>

    </div>
</template>

<script>

    import {mapMutations} from "vuex";

    export default {
        name: 'Home',
        components: {},
        mounted() {
            this.$router.push({'path': '/home/dashboard'})
        },
        updated() {
        },
        data() {
            return {}
        },
        methods: {
            ...mapMutations(['saveToken']),
            goRoute(compName) {
                this.$router.push({'path': '/home/' + compName})
            },
            logout() {
                this.saveToken({"token": ''})
            }
        }
    }
</script>

<style scoped>
    .home {
        height: 100%;
        padding: 0;
        margin: 0;
    }

    .outer {
        height: 100%;
        box-sizing: border-box;
    }

    .el-header {
        background-color: #B3C0D1;
        color: #333;
        line-height: 60px;
    }

    .el-aside {
        color: #333;
    }
</style>